Skip to content

fix: assign product quantities by id match instead of index in addNew…#113

Open
ZIADMOHAMED-A8 wants to merge 1 commit into
Ovi:masterfrom
ZIADMOHAMED-A8:fix/cart-quantity-mismatch
Open

fix: assign product quantities by id match instead of index in addNew…#113
ZIADMOHAMED-A8 wants to merge 1 commit into
Ovi:masterfrom
ZIADMOHAMED-A8:fix/cart-quantity-mismatch

Conversation

@ZIADMOHAMED-A8
Copy link
Copy Markdown

Bug: Wrong quantities assigned to products in addNewCart
Problem
When adding a cart, product quantities were being assigned by index after filtering from frozenData.products. Since filter returns products in their stored order rather than the order they were passed in the request, the quantities were mismatched — e.g. sending {id:6, qty:1}, {id:4, qty:3} would result in id:6 getting qty:3 and id:4 getting qty:1.
Fix
Instead of relying on index to match quantities, we now use productIds.indexOf(p.id) to look up the correct quantity for each product by its id, regardless of the order products are returned from the data store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant